<template>
	<view>
		<view class="">

			<view class="">
				合计：{{jinecount}} 元
				实际消费：{{shijijinecount}} 元
			</view>
			<!-- <button type="default" @click="deleteall"> 删除</button> -->

			<view class="" v-for="(item,index) in bill" :key="index">
				<uni-list>
					<uni-list-item :title="item.order" :note="item.date" :rightText="item.username" />
				</uni-list>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				userInfo: {},
				hasUserInfo: true,
				bill: [],
				jinecount: 0,
				shijijinecount:0
			};
		},
		onLoad() {
			console.log("onLoad")
		},
		onShow() {
			console.log("onShow")
			this.getZhangdan();

		},
		computed: {
			nickName() {

				const name = uni.getStorage({
					key: 'storage_userInfo',
					success: function(res) {
						console.log('storage_userInfo', res.data.nickName)
						return res.data.nickName
					}
				})
				return name
			}
		},
		methods: {
			getZhangdan() {
				uniCloud.callFunction({
					name: "getZhangdan",
					data: {
						username: "唐超"
					}
				}).then(res => {
					this.bill = res.result.data
					console.log("bill", res.result.data)

					let sum = 0;
					this.bill.forEach((item) => {
						sum += item.order;
					});
					//返回
					this.jinecount = sum;
					this.shijijinecount = this.jinecount / 0.7


				}).catch(error => {
					console.log("error", error)
				})

			},
			deleteall() {
				uniCloud.callFunction({
					name: "deleteAll"
				}).then(res => {
					console.log("res", res)
				}).catch(error => {
					console.log("error", error)
				})

			}

		}
	};
</script>

<style>

</style>
